package org.example.controller;

import org.example.annotation.ApiSecurity;
import org.example.enums.SecurityTypeEnum;
import org.example.utils.JwtUtils;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * Description: 令牌签名控制层
 * @author shenguangyang
 */
@RestController
@RequestMapping("token")
public class TokenSignController {

    @GetMapping("find")
    @ApiSecurity(SecurityTypeEnum.SIGN)
    public Map<String,Object> findUser(@RequestParam("uid") String uid) {
        Map<String,Object> map = new HashMap<>(16);
        map.put("username","guangyang");
        map.put("phone","17261617669");
        return map;
    }

    @PostMapping("save")
    @ApiSecurity(SecurityTypeEnum.CRYPTO)
    public void save(@RequestBody Map<String,Object> map) {
        System.out.println("保存成功 ---> " + map.toString());
    }

    @PostMapping("login")
    public String login(@RequestBody Map<String,Object> map) {
        return JwtUtils.encode("沈光阳",120,map);
    }
}
